home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 49 / Amiga Format CD49 (2000-01-17)(Future Publishing)(GB)(Track 1 of 3)[!][issue 2000-02].iso / -serious- / misc / miggy / miggy.doc < prev    next >
Text File  |  1999-11-29  |  15KB  |  394 lines

  1. --------------------------------------------------------------------------
  2. Initial release by Olly 18-Nov-99
  3. --------------------------------------------------------------------------
  4.  
  5. Miggy - Yet another attempt at artificial intelligence :)
  6.  
  7.  
  8. PROGRAM HISTORY: (a must read!)
  9. ----------------
  10. Late '89 (<- True!)
  11.  
  12. Purchase of new A500, began with (Yuk!) AmigaBasic, started working with
  13. specific responses to user input.  After 15 mins coding, my brain
  14. subconciously calculated a large number beginning with 5 and many decimal
  15. places concerning the number of specific responses required before project
  16. completion.  Needless to say, scrapped!
  17.  
  18. Early '90
  19.  
  20. Changed coding language to ASM.
  21.  
  22. *Large time-warp here - Left Army in mid '95*
  23.  
  24. 11-05-99
  25.  
  26. After MANY projects and a BBS filebase (FB11 - Max's), I came across a
  27. project from Aminet called HAL9001 V1.42 by Simon Champion, written late
  28. '98 in Amos Pro.  His idea was a step forward, to output responses using a
  29. certain formula based on Nouns and Verbs.  Amos being a somewhat buggy and
  30. unstable language, I couldn't get it to reply a single sentence without
  31. crashing with a dead-end (80000006) alert every time, but it started me
  32. thinking.
  33.  
  34. 12-05-99
  35.  
  36. 24 hour thinktank.  Experimented with a few routines.  Input parser routine
  37. complete.  Working out file formats (preferably editable ASCII), basic
  38. program structure complete.  Can't sleep.
  39.  
  40. 13-05-99
  41.  
  42. Main problem with this kind of program is that 90% completion is required
  43. before first test can be established.  Ran a few tests - deemed fairly
  44. successful.  Did some more tweaking, doesn't crash randomly anymore :)
  45.  
  46. 14-05-99
  47.  
  48. Complete!  Miggy uses particular files based on mood and emotion, such as
  49. good and bad subject, happy and sad etc.  Words in dictionary require their
  50. own mood/emotion and meaning.  Responses gleaned from these facts.  Miggy
  51. has the ability to learn.  Responses randomly fetched once mood/emotion is
  52. determined.  Code pretty patched and messy though :(
  53.  
  54. Program upkeep difficult, as later stages of testing showed.  Program
  55. ability to learn hampered by requirement of many more moods/emotions than
  56. originally catered for.  Therefore, brain recalculates number - result much
  57. smaller this time, albeit still too large for practicality.  Especially
  58. when in "Learn" mode, too cumbersome to teach and too many variables based
  59. on what mood/meaning I myself deem a particular word to have and what
  60. someone else does.  Hmm..  Scrapped! (again)
  61.  
  62. 15-05-99
  63.  
  64. Major rethink.  Need to cut down on number of files used.  Also want to
  65. cater for different languages, as I would like to see this program spread
  66. worldwide with users creating either their own or adding to existing
  67. files in their own language.  "Learn" mode must be simplistic, as users
  68. might tire of this and leave it alone.  Decided to keep input parsing
  69. routine as it worked fine. :þ  What kind of algorithm is required to
  70. calculate an appropriate response?  Is this the kind of thing that lonely
  71. people do?  Is this concept possible at all?  [sigh].. Still can't sleep.
  72.  
  73. 16-05-99
  74.  
  75. Some more experimentation with ideas and routines.  Major routines
  76. reworked completely to cater for file formats.  Attempting to maintain
  77. maximum speed for when datafiles grow large.  How many words in the English
  78. (or then again, any other) language?  65,535 should be enough, as most
  79. English dictionaries only contain about 30,000 or so.  Response parser
  80. EXTREMELY fast but has spurious problems I'm unable to pin down.  Memory
  81. requirements reduced massively (to 8848 bytes!) by slowing down response
  82. parser slightly.  Some more teeny bugs squished.
  83.  
  84. 17-05-99
  85.  
  86. Prettied up the output, tested some more.  Found another bug that was
  87. subsequently squished.  2 major sub-routines placed in-line to help
  88. fatter processors with instruction caches.  After more testing, determined
  89. that random response-fetch routine too hit and miss.  Replaced with smaller
  90. and more intelligent method.
  91.  
  92. Complete!  The fully reworked Miggy now works fine without any crashing or
  93. wierd binary output.  Fully customizable for most languages with minimal
  94. memory requirements.  Even with little data in files responses becoming
  95. intelligent.  Should work on Kick 1.3 machines as well (does 1.3 understand
  96. the assign "PROGDIR:"?  If not - assign it :)  Executable size under 2K.
  97.  
  98. ---------------------------------------------------------------------------
  99.  
  100. So now you know what this project is all about.  If you didn't read the
  101. program history, I strongly suggest you do so.  I'll stop typing in the
  102. meantime..
  103.  
  104. All righty then!  Maybe the next question is WHY?  I dunno really, because
  105. it was there - or maybe it wasn't.  I've seen a few of these programs
  106. floating around for some time, but none of them held my attention for very
  107. long, as the responses calculated (assumed?) didn't appear too intelligent
  108. but rather more convoluted, and Deep Blue (the chess champion) is WAY outta
  109. my price range and also lacks personality.
  110.  
  111. In any case - the deed has been done.  At this time I consider Miggy to be
  112. capable of simple hello, goodbye, yes & no type conversations with little
  113. available data.  After some more time has been spent teaching it, Miggy's
  114. able to create better matches due to greater availablity of data and wider
  115. choice.  I would like to see its capabilities with a large (1+ meg)
  116. response file!
  117.  
  118.  
  119. STARTING MIGGY:
  120. ---------------
  121. Miggy is a CLI only program - there's no icon.  If you add an icon and
  122. start it then it's sure to crash as I didn't build it to be started that
  123. way.  Create a script that calls Miggy then start the script with an icon
  124. that calls C:IconX if you must have an icon for it.
  125.  
  126. From the CLI, type DH1:Miggy/Miggy, or wherever it lives.
  127.  
  128. It will load its MiggyText file, Dictionary and Response file.  You'll then
  129. be faced with a "->" prompt.  From here just type "Hello" for example, and
  130. you'll be on your way.
  131.  
  132.  
  133. The input parser knows only 2 commands:
  134.  
  135. "#l" - Enter "Learn" mode (See: TEACHING)
  136. "#q" - Quit
  137.  
  138. The maximum input length Miggy reads at any prompt is 75 characters.
  139.  
  140.  
  141. Total memory requirements are:
  142.  
  143. 8848 + Dictionary file length + Response file length.
  144.  
  145. The MiggyText file looks like this:
  146.  
  147. ---------------------------------------------------------------------------
  148.  
  149. Miggy V1.00 © Olly Koenders Australia 17-05-99.
  150. Loading reference files..
  151. Dictionary words: 
  152. Response records: 
  153. Learn mode activated - Type word/sentence to learn..
  154. Type 3 generic responses: 1st-Vague, 2nd-Semi coherent, 3rd-Understanding
  155. Learn mode deactivated.
  156. Match: 
  157. abcdefghijklmnopqrstuvwxyz';:>8^-()þ]}
  158. ABCDEFGHIJKLMNOPQRSTUVWXYZ';:>8^-()þ]}
  159.  
  160. ---------------------------------------------------------------------------
  161.  
  162. These lines can be edited to your liking/language.  I wonder if any lamers
  163. will put their own name at the top..?  There MUST be 10 lines and each line
  164. MUST end with a 0x0a/#10/linefeed or expect problems.
  165.  
  166.  
  167. THE INPUT PARSER:
  168. -----------------
  169. ..is the "->" prompt.  From here anything you type will be split into
  170. single words, and these characters:
  171.  
  172. abcdefghijklmnopqrstuvwxyz';:>8^-()þ]}
  173.  
  174. ..if found in the input will be changed into these:
  175.  
  176. ABCDEFGHIJKLMNOPQRSTUVWXYZ';:>8^-()þ]}
  177.  
  178. Any others will be masked so that only the characters from the second line
  179. will end up in the dictionary.  Typing "Hello,there!" will become
  180. "HELLO THERE " and entering "You're not" will become "YOU'RE NOT".  The
  181. format for these 2 lines must be:
  182.  
  183. lowercasecharactersinyourlanguage+anyothersyouwant
  184. UPPERCASECHARACTERSINYOURLANGUAGE+anyothersyouwant
  185.  
  186. All lowercase characters in the first line must correspond to the uppercase
  187. characters in the second.  The apostrophe "'" is there for words like
  188. "Can't" etc., and the others are for smileys. :)
  189.  
  190. Uppercasing the input words is essential as the computer sees "This" and
  191. "THIS" as 2 completely different things.
  192.  
  193. I recommend you don't add "!" or "?" as they are normally posted at the end
  194. of a word, and words like "YES" and "YES!" will end up in the Dictionary -
  195. they are the same thing.
  196.  
  197. Miggy will attempt to respond the best way it can determined by your input
  198. and the input of others from previous sessions.
  199.  
  200.  
  201. TEACHING:
  202. ---------
  203. Ok, in order to teach, we need to know how Miggy learns.  Imagine for a
  204. moment your own children.  If they are unattentive or the subject matter
  205. just doesn't hold their interest, they'll simply refuse to learn - note
  206. that this is almost a fully automatic process with the human psyche, and
  207. most animals too.  That aside, and remembering Miggy will always be fully
  208. attentive, the teaching process rests ENTIRELY on yourselves.  (oooh!)
  209.  
  210. Anyhoo.. You have to carefully consider what Miggy learns, and how to spell
  211. it out.  Miggy uses 2 files for any intelligent decision: The Dictionary
  212. and the Response files.  The Dictionary file is continually updated whether
  213. teaching or not.  Any word you typed in a sentence not found in the
  214. dictionary will be automatically added to it.  That reminds me..
  215.  
  216. Spelling people, SPELLING!  Argh!  I can't begin to describe how atrocious
  217. much of the spelling is that I've seen in documentation!  I'm sure there's
  218. a trend circulating amongst you lot.  For example, many words have been
  219. butchered simply by replacing "e" and "i"  with "a":
  220.  
  221. "paramater" should be "parameter"
  222. "infinate"     ""     "infinite"
  223. "verticle"     ""     "vertical"
  224.  
  225. Spelling mistakes generated by persons not using their native language
  226. however, are always excusable.  In any case, the ability for another
  227. person to use Miggy successfully is highly unlikely when many of the words
  228. in the Dictionary entered by you are misspelled.  If you have received a
  229. version of Miggy from someone else then your best initial course of action
  230. would be to spell-check the Dictionary :þ
  231.  
  232. Miggy's response capability is limited directly by what has been learned.
  233. The Response file contains fields of pre-determined responses to word
  234. combinations.  The decision-making algorithm is as follows:
  235.  
  236. You type a sentence, then matches of words from your sentence found in a
  237. field will derive a percentage as:
  238.  
  239. (# of words in your sentence + # of words from field) / 2 = X
  240.  
  241. % = # of matched words / X
  242.  
  243. The order of the words makes no difference.
  244.  
  245. The entire Response file is searched to determine the field with the
  246. highest percentage match.  A match of 100% immediately concludes the
  247. search.  This percentage is then used to respond as:
  248.  
  249. 000.0 -> 033.3% = use response #1 from this field
  250. 033.4 -> 066.6% =      ""      #2       ""
  251. 066.7 -> 100.0% =      ""      #3       ""
  252.  
  253. Responses typed by you in Learn mode should be as generic as possible, that
  254. is to say, hopefully devoid of subject matter.  Example:
  255.  
  256. ---------------------------------------------------------------------------
  257.  
  258. Learn mode activated - Type word/sentence to learn..
  259.  
  260. L>You are
  261.  
  262. Type 3 generic responses: 1st-Vague, 2nd-Semi coherent, 3rd-Understanding
  263.  
  264. 1>I am what
  265.  
  266. 2>I think so
  267.  
  268. 3>Of course I am :)
  269.  
  270. ---------------------------------------------------------------------------
  271.  
  272. Type "#l" to enter "Learn" mode.
  273.  
  274. You'll be presented with some text informing of the change in mode, and
  275. the prompt and subsequent type will change colour.
  276.  
  277. From here, you have to carefully consider what to type.  Single words are
  278. OK although teaching Miggy the meaning to "It" could be difficult, as how
  279. miggy uses it in a response computes from what the user typed to begin
  280. with.  The longer the sentences you make Miggy learn, the greater the
  281. combination of differing words and the less chance that someone else would
  282. type a sentence of sufficient match for an appropriate response.
  283.  
  284. Confused yet?
  285.  
  286. If you teach Miggy "You are" and you enter later exactly "Are you", the
  287. match will still be 100%.  If Miggy already knows "You are" and you enter
  288. something like "Are you intelligent?", the percentage obtained will be over
  289. 66.6%, and therefore would use the response "OF COURSE I AM :)".  If you
  290. then ask Miggy "Are you intelligent enough to understand?", then the
  291. response percentage would be around 50.0% and would use response #2.  The
  292. exact same responses will be obtained by swapping "Are you" with "You are"
  293. in the above examples.
  294.  
  295. You can also help yourself teaching by simply beginning, carrying out, and
  296. then ending an entire conversation while teaching the whole time, chained
  297. together by some of the responses you type while in "Learn" mode. 
  298.  
  299. Naturally, generic conversation would work best as you could imagine but
  300. you MUST type 3 responses!  There's NO abort function.  When in learn mode
  301. you should check your spelling and grammar before pressing [enter].  Use
  302. smileys ":)" for responses.  It all adds to the fun.
  303.  
  304. If you're unsure as to whether Miggy already knows what you want him to
  305. learn, then from outside "Learn" mode, type what you want to teach.  If the
  306. match is less than 100% you know that he doesn't already know it.  If the
  307. match is fairly high but still not 100% - say 80, then teach it anyway as
  308. it all adds up to more useful data.
  309.  
  310.  
  311. WARNING:
  312. --------
  313. Do NOT edit the Dictionary or Response files unless you KNOW what you're
  314. doing!  Editing the Dictionary in a random manner may render the Response
  315. file and Miggy completely useless, and you'll have to start the Dictionary
  316. and Response files all over again!
  317.  
  318. Dictionary file format:
  319.  
  320. WORDINUPPERCASE[return]
  321. NEXTWORD[return]
  322. . . .[return]
  323. . . .[return]
  324. LASTWORD[return]
  325.  
  326.  
  327. Response file format: (in HEX)
  328.  
  329. Numberofwords-1 + wordnumber + wordnumber
  330.  
  331.     01             0024         0046
  332.  
  333. Response field = Sentence learned -> 0100240046 +
  334.                  Response #1      -> 0300180006001A000E +
  335.                  Response #2      -> 00002D +
  336.                  Response #3      -> 0200440003000A
  337.  
  338.  
  339. TO CONVERT TO ANOTHER LANGUAGE: (probably the easiest way!)
  340. -------------------------------
  341. Delete the Responses file.
  342.  
  343. Edit the Dictionary to contain a MINIMUM of one word.  Terminating each
  344. word with a linefeed (0x0a).
  345.  
  346. Edit the MiggyText file to your language, terminating each of the 10 lines
  347. with a linefeed.
  348.  
  349. Start Miggy and it'll go straight into "Learn" mode.  Teach Miggy as much
  350. as possible.
  351.  
  352. Create a new copy of this doc file in your own language, and take credit
  353. for it at the top of this file with the date. :)
  354.  
  355. Archive all the original files together with your native language files and
  356. call the archive:
  357.  
  358.  Miggy1(First 3 letters of language + Response file KB).lha.
  359.  
  360.  Example:  English version and Response file at 52,000 bytes
  361.  
  362.  Miggy1ENG052.lha
  363.  Miggy1ENG052.readme
  364.  
  365. Send it to Aminet and all your friends, and I'll thank you very much! :)
  366.  
  367.  
  368. WHAT I HOPE WILL HAPPEN: 8)
  369. ------------------------
  370. People download Miggy.
  371. Enjoy and teach it as much as possible.
  372. Enter their name at the top of this doc file with the date.
  373. Archive it all back together and name the archive as above.
  374. Send to Aminet and all their friends.
  375. And I'll thank them very much too! :)
  376.  
  377.  
  378. WHAT MIGHT HAPPEN:
  379. ------------------
  380. Miggy's fame grows.
  381. Spies worldwide use it to send secret messages to their governments.
  382. Urban Mueller arrested by Interpol.
  383. Miggy dies a lonely death in Cyberspace..
  384.  
  385.  
  386. FUTURE:
  387. -------
  388. Maybe an abort function in the "Learn" mode.
  389. Fully automatic learning - IF I can figure a way :)
  390. A command to make it sleep and go away for a random period of time then
  391. pop back up demanding solace of some kind. :þ
  392. Get it to execute CLI commands. :)
  393. Include a spell-checker because my girlfriend REALLY needs one! [sigh]
  394.